package com.xiehao.springbootmybaits.controller;

import com.xiehao.springbootmybaits.entity.ClassInfo;
import com.xiehao.springbootmybaits.entity.Student;
import com.xiehao.springbootmybaits.service.ClassInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Controller
@RequestMapping("/classInfo")
public class ClassInfoController {

    @Autowired
    ClassInfoService classInfoService;

    @GetMapping("/{classno}")
    public String getClass(@PathVariable Integer classno, Model model){
       ClassInfo classInfo = classInfoService.getClassInfo(classno);
       model.addAttribute("classInfo",classInfo);
        return "classInfo";
    }
}
